#include "functions.h"
#include <vector>
#include "../../externals/PixelToaster.h"

// ==================================================================================================
// Find the dot product of two vectors
// ==================================================================================================
float DotProduct(const Vector4& v1, const Vector4& v2) {
    return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}

float DotProduct(const Vector4& v1, float x, float y, float z) {
    return (v1.x*x + v1.y*y + v1.z*z);
}

// =================================================================================================
// Find the crossproduct of two vectors
// =================================================================================================
Vector4 CrossProduct(const Vector4& vec1, const Vector4& vec2) {
    float i = (vec1.y * vec2.z - vec1.z * vec2.y);
    float j = -(vec1.x * vec2.z - vec1.z * vec2.x);
    float k = (vec1.x * vec2.y - vec1.y * vec2.x);

    Vector4 tempvec(i, j, k);
    return tempvec;
}

// =================================================================================================
// Rotate about an arbitrary axis
// =================================================================================================
void RotateArb(const Vector4& vec, float radians, Matrix4x4& mat) {
}

// =================================================================================================
// Rotation functions
// =================================================================================================
void RotateX(float radians, Matrix4x4& mat) {
    Matrix4x4 temp;

    temp.m00 = 1.0f;
    temp.m11 = cos(radians);
    temp.m12 = sin(radians);
    temp.m21 = -sin(radians);
    temp.m22 = cos(radians);

    mat *= temp;
}

void RotateY(float radians, Matrix4x4& mat) {
    Matrix4x4 temp;

    temp.m00 = cos(radians);
    temp.m02 = sin(radians);
    temp.m11 = 1.0f;
    temp.m20 = -sin(radians);
    temp.m22 = cos(radians);

    mat *= temp;
}

void RotateZ(float radians, Matrix4x4& mat) {
    Matrix4x4 temp;

    temp.m00 = cos(radians);
    temp.m01 = -sin(radians);
    temp.m10 = sin(radians);
    temp.m11 = cos(radians);
    temp.m22 = 1.0f;

    mat *= temp;
}

// ==== End of Rotation Functions ==================================================================


